package com.compass.doctor.ui.patient

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.activity.viewModels
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import com.compass.doctor.base.BaseVBActivity
import com.compass.doctor.databinding.ActivityAddBankcardBinding
import com.compass.doctor.databinding.ActivityAddCaseHistoryBinding
import com.compass.doctor.databinding.ActivityCaseHisDetailsBinding
import com.compass.doctor.preview.PreviewPicActivity
import com.compass.doctor.ui.home.adapter.PatientPictureAdapter
import com.compass.doctor.ui.home.viewmodel.InquiryOrderViewModel
import com.compass.doctor.ui.mine.AddBankCardActivity
import com.compass.doctor.ui.mine.viewmodel.IntegralViewModel
import com.compass.framework.decoration.NormalItemDecoration
import com.compass.framework.ext.onClick
import com.compass.framework.model.AddBankCard
import com.compass.framework.model.CaseHistory
import com.compass.framework.utils.dpToPx
import com.luck.picture.lib.entity.LocalMedia

/**
 * Description： 病历详情 非His--暂时作废
 * Date:2024/2/1 17:43
 */
class CaseHistoryDetailsActivity : BaseVBActivity<ActivityCaseHisDetailsBinding>() {

    companion object {
        fun start(context: Context, caseHistory: CaseHistory) {
            val intent = Intent(context, CaseHistoryDetailsActivity::class.java)
            intent.putExtra("caseHistory", caseHistory)
            context.startActivity(intent)
        }
    }

    private var pics: MutableList<String> = mutableListOf()
    private lateinit var patientPictureAdapter: PatientPictureAdapter
    private lateinit var caseHistory: CaseHistory
    override fun initView(savedInstanceState: Bundle?) {


    }

    override fun initData() {
        caseHistory = intent.serializable("caseHistory")!!
        pics=caseHistory.diseaseDescription
        mBinding.tvDiseaseDescriptionText.text=caseHistory.diseaseDescriptionText
        initRcyPicture()

    }


    private fun initRcyPicture() {
        patientPictureAdapter = PatientPictureAdapter(2)
        mBinding.rcyPicture.apply {
            layoutManager = LinearLayoutManager(
                this@CaseHistoryDetailsActivity,
                LinearLayoutManager.VERTICAL,
                false
            );
            adapter = patientPictureAdapter
            addItemDecoration(NormalItemDecoration().apply {
                setBounds(top = dpToPx(5), bottom = dpToPx(5))
            })
        }
        patientPictureAdapter.onItemClickListener = { view: View, position: Int ->
            var loacls = ArrayList<LocalMedia>()
            var localMedia: LocalMedia
            for (pic in pics) {
                localMedia = LocalMedia()
                localMedia.path = pic
                loacls.add(localMedia)
            }
            if (loacls.isNotEmpty()) {
                PreviewPicActivity.start(this, position, loacls)
            }
        }
        patientPictureAdapter.setData(pics)

    }

}